import { defineStore } from 'pinia';
import homeApi from '@/api/modules/home';

const halllink = defineStore({
  id: 'halllink',
  state: () => {
    return {
      activityItem: '',
      linkItem: '',
      listActivityLink: <any>[],
      listPanelLink: <any>[],
    };
  },
  persist: true,
  getters: {
    getActivityItem: (state) => state.activityItem,
    getLinkItem: (state) => state.linkItem,
    getListActivityLink: (state) => state.listActivityLink,
    getListPanelLink: (state) => state.listPanelLink,
  },
  actions: {
    setActivityItem(string: string) {
      this.activityItem = string;
    },
    setLinkItem(string: string) {
      this.linkItem = string;
    },
    setListActivityLink(array: any[]) {
      this.listActivityLink = array;
    },
    setListPanelLink(array: any[]) {
      this.listPanelLink = array;
    },
    queryHalllinkConfig(){
      homeApi.playHallLinkConfig({}).then((response:any)=>{
        if(response.code === 200){
          this.setActivityItem(response.data.activityItem || '');
          this.setLinkItem(response.data.linkItem || '');
          this.setListActivityLink(response.data.listActivityLink || []);
          this.setListPanelLink(response.data.listPanelLink || []);
        }
      });
    }
  },
});

export default halllink;
